#include <stdio.h>
#define N 10
struct stud
{
    int num;       // 学号
    char name[10]; // 姓名
    int score[3];  // 3门课成绩
    int sum;       // 总分
};

int main()
{
    struct stud a[N];
    int n, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d %s %d %d %d", &a[i].num, a[i].name, &a[i].score[0], &a[i].score[1], &a[i].score[2]);
    for (i = 0; i < n; i++)
        a[i].sum = a[i].score[0] + a[i].score[1] + a[i].score[2];

    double avg = 0;
    for (i = 0; i < n; i++)
    {
        avg += a[i].sum;
    }
    avg /= n * 3;
    int max = 0;
    for (i = 0; i < n; i++)
    {
        printf("%d %s %d %d %d %d\n", a[i].num, a[i].name, a[i].score[0], a[i].score[1], a[i].score[2], a[i].sum);
        if (a[max].sum < a[i].sum)
            max = i;
    }

    printf("总平均分=%lf\n", avg);
    printf("%d %s %d %d %d %d\n", a[max].num, a[max].name, a[max].score[0], a[max].score[1], a[max].score[2], a[max].sum);
    return 0;
}
